package org.example.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.example.annation.UIdValidation;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {
    @NotNull(message = "当前用户的id必须定义")
    private Integer id;
    @NotNull(message = "用户名不能为null")
    @Length(min = 8, max = 12, message = "用户名长度必须在8-12之间")
    @Pattern(regexp = "^[\\u4e00-\\u9fa5a-zA-Z0-9]{8,12}$",message = "用户名必须是英文和数字")
    private String name;
    @NotNull(message = "密码不能为null")
    @Pattern(regexp = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[\\s\\S]{8,16}$",message = "至少8-16个字符，至少1个大写字母，1个小写字母和1个数字，其他可以是任意字符")
    private String pass;
    @NotNull(message = "电子邮件不能为null")
    //不支持.的存在  jason@qqcom  true
    @Email
    private String email;
    @NotNull(message = "年龄不能为null")
    @Pattern(regexp = "^(0?[1-9]|[1-9][0-9])|^120",message = "最大不超过120岁")
    private String age;
    //身份证 ---由于国外不支持中国的身份证验证，所以只能自己自定义
    @UIdValidation
    private String uid;

}
